<?php


namespace app\api\controller;


use app\admin\model\FinanceType;
use think\Controller;
use think\Request;

class Finance extends Controller
{
    public function getFinanceType(){
        $res = [];
        $financeType = new FinanceType();
        $where['status'] = 1;
        $list = $financeType->getAll($where);
        if($list == null){
            $res['data']['code'] = 0;
            $res['data']['msg'] = '获取失败';
        }else{
            $res['data']['code'] = 1;
            $res['data']['msg'] = '获取成功';
            $res['data']['list'] = $list;
        }
        $res['status'] = 200;
        echo json_encode($res);
    }

    public function getFinanceDetail(Request $request){
        $res = [];
        $data = $request->post();
        if(!isset($data['pid'])){
            $res['status'] = 400;
            echo json_encode($res);die;
        }

        $performer = new \app\admin\model\Finance();
        $where['pid'] = $data['pid'];
        $where['status'] = 1;
        $list = $performer->getAll($where);
        if($list == null){
            $res['data']['code'] = 0;
            $res['data']['msg'] = '获取失败';
        }else{
            $res['data']['code'] = 1;
            $res['data']['msg'] = '获取成功';
            $res['data']['list'] = $list;
        }

        $res['status'] = 200;
        echo json_encode($res);
    }
}